package com.rain.service.remoting;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestController;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.rain.bee.service.UserService;
import com.rain.bee.service.vo.UserVo;

@RestController
public class UserServiceImpl implements UserService {

	Logger logger = LoggerFactory.getLogger(this.getClass());

	@HystrixCommand(fallbackMethod = "getUserByIdFallBack")
	@Override
	public UserVo getUserById(UserVo user) {
		UserVo vo = new UserVo();

		vo.setUserName("张三");

		logger.info("查询用户信息:{}", vo.getUserName());

		return vo;
	}

	public UserVo getUserByIdFallBack(UserVo user, Throwable throwable) {

		logger.error("为啥熔断了",throwable);
		
		UserVo vo = new UserVo();

		vo.setUserName("熔断");

		logger.info("熔断方法被调用：{}", vo.getUserName());

		return null;
	}

	@Override
	public List<UserVo> getUsers(UserVo user) {
		logger.info("查询用户信息:{}", user.getUserName());
		return null;
	}

}
